from threading import Thread

# 创建任务
# def func(name):
#     for i in range(100):
#         print(name,i)
#
# if __name__ == '__main__':
#     # 创建线程
#     t1 = Thread(target=func,args=("陈奕迅",))  # 此时传参 它是元组，要加个逗号
#     t2 = Thread(target=func, args=("王菲",))
#     t3 = Thread(target=func, args=("杨幂",))
#
#     # 启动线程
#     t1.start()
#     t2.start()
#     t3.start()


# 多线程调用，写法二  -> 需要继承线程类，对方法进行重写
class MyThread(Thread):
    def __init__(self,name):
        super(MyThread,self).__init__()
        self.name = name

    def run(self):
        for i in range(100):
            print(self.name,i)

if __name__ == '__main__':
    t1 = MyThread('陈奕迅')
    t2 = MyThread('王菲')
    t3 = MyThread('杨幂')

    t1.start()
    t2.start()
    t3.start()

